package freespiritsocial.io.user.ui.fragment.mine

import android.os.Bundle
import android.view.View
import freespiritsocial.io.user.R
import freespiritsocial.io.user.base.BaseFragment
import freespiritsocial.io.user.databinding.FrgContactUsBinding
import freespiritsocial.io.user.ext.hideSoftKeyboard
import freespiritsocial.io.user.ext.setTitle
import freespiritsocial.io.user.handle.BackHandle
import freespiritsocial.io.user.viewmodel.ConctactUsViewModel
import freespiritsocial.io.user.weight.MyPickupViewBuilder
import me.hgj.jetpackmvvm.ext.nav

class ConctactUsFrg: BaseFragment<ConctactUsViewModel,FrgContactUsBinding>() {
    override fun layoutId(): Int = R.layout.frg_contact_us
    private val topicList = arrayListOf("Advertising/Partnership","Issue","Feedback","Other")

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.model = mViewModel
        mDatabind.click = Click()
        mDatabind.root.setTitle(getString(R.string.contact_us))
    }

    inner class Click: BackHandle {
        override fun goBack() {
            nav().navigateUp()
        }

        fun selectTopic() {
            hideSoftKeyboard(requireActivity())
            MyPickupViewBuilder(
                requireContext(),
            ) { i: Int,_: Int,_: Int,_: View? ->
                mViewModel.topic.set(topicList[i])
            }.build<String>().apply {
                setPicker(topicList)
            }.show()
        }

        fun submit() {
            hideSoftKeyboard(requireActivity())
            mViewModel.contactUs {
                nav().navigateUp()
            }
        }
    }
}